package ee.ut.cs.mc.l2;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

/**
 * @author Kaarel Jõgeva
 */
public class Greeter extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_greeter);

        Button btn = (Button) findViewById(R.id.greetBtn);
        btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                EditText nameField = (EditText) findViewById(R.id.nameField);
                TextView nameView = (TextView) findViewById(R.id.nameView);
                nameView.setText("Greetings to " + nameField.getText().toString() + "!");
            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_greeter, menu);
        return true;
    }
}
